<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <title>驾驶证绑定</title>
    <link rel="stylesheet" href="<c:url value='/resource/wechat/css/frozen.css'/>">
    <link rel="stylesheet" type="text/css" href="<c:url value='/resource/wechat/css/main.css'/>"/>
    <link type="text/css" href="<c:url value='/resource/wx/newcss/common.css'/>" rel="stylesheet"/>
    <script type="text/javascript" src="<c:url value='/resource/wx/newjs/jquery-2.0.min.js'/>"></script>
    <script type="text/javascript" src="<c:url value='/resource/wx/newjs/common.js'/>"></script>
</head>
<body class="body_bg" ontouchstart>

<section class="ui-container">

    <c:if test="${mange == '0' || rz == '0'}">
        <div class="ui-form-item ui-form-item-show ui-border-b bg_fff row">
            <label style="color: #777; width: 118px;">
                档案编号：
            </label>
            <input type="text" placeholder="请输入档案编号" value="" id="hyzk" maxlength="12" onkeyup="this.value=this.value.toUpperCase()" >
        </div>
        <div class="ui-form-item ui-border-b bg_fff">
            <label style="color: #777; width: 118px;">
                驾驶证编号：
            </label>
            <input type="text" placeholder="请输入驾驶证编号" value="" id="mz" maxlength="18" onkeyup="this.value=this.value.toUpperCase()" >
        </div>

        <div style="font-size: 14px;padding: 0px 15px;box-sizing: border-box;color: red;">
            驾驶证信息未绑定或未查询到匹配信息
        </div>

        <div class="ui-btn-wrap">
            <button class="ui-btn-lg ui-btn-primary" id="btn_query" onclick="baoCun();">
                确认绑定
            </button>
        </div>

    </c:if>

    <c:if test="${mange == '-9'}">
        <div class="ui-form-item ui-form-item-show ui-border-b bg_fff row">
            <label style="color: #777; width: 118px;">
                档案编号：
            </label>
            <input type="text" placeholder="请输入档案编号" value="${diverinfos.dcn}" id="hyzk" maxlength="12" onkeyup="this.value=this.value.toUpperCase()" >
        </div>
        <div class="ui-form-item ui-border-b bg_fff">
            <label style="color: #777; width: 118px;">
                驾驶证编号：
            </label>
            <input type="text" placeholder="请输入驾驶证编号" value="${diverinfos.arc_id}" id="mz" maxlength="18" onkeyup="this.value=this.value.toUpperCase()" >
        </div>

        <div style="font-size: 14px;padding: 0px 15px;box-sizing: border-box;color: red;">
            驾驶证信息认证不通过
        </div>

        <div class="ui-btn-wrap">
            <button class="ui-btn-lg ui-btn-primary" id="btn_query" onclick="baoCun();">
                修改绑定
            </button>
        </div>

    </c:if>

    <c:if test="${mange == '1'}">
        <div class="ui-form-item ui-form-item-show ui-border-b bg_fff row">
            <label style="color: #777; width: 118px;">
                档案编号：
            </label>
            <input type="text" placeholder="请输入档案编号" value="${diverinfos.dcn}" id="hyzk" maxlength="12" onkeyup="this.value=this.value.toUpperCase()" >
        </div>
        <div class="ui-form-item ui-border-b bg_fff">
            <label style="color: #777; width: 118px;">
                驾驶证编号：
            </label>
            <input type="text" placeholder="请输入驾驶证编号" value="${diverinfos.arc_id}" id="mz" maxlength="18" onkeyup="this.value=this.value.toUpperCase()" >
        </div>

        <div style="font-size: 14px;padding: 0px 15px;box-sizing: border-box;color: red;">
            驾驶证信息认证通过
        </div>
    </c:if>

    <br/>
    <div id="result" style="font-size: 14px;padding: 0px 15px;box-sizing: border-box;color: blue;"></div>
    <%--<div style="font-size: 14px;padding: 0px 15px;box-sizing: border-box;">&nbsp;&nbsp;温馨提示：绑定车辆信息后，平台将提供您驾驶证、检车到期微信推送提醒服务。</div>--%>
</section>
</body>
<script>
    <%--<c:if test="${rzResult=='0'}">【未认证】</c:if>--%>
    <%--<c:if test="${rzResult=='1'}">【已认证】</c:if>--%>
    <%--<c:if test="${rzResult=='2'}">【认证中】</c:if>--%>
    <%--<c:if test="${rzResult=='-9'}">【未通过认证】</c:if>--%>
    $(function(){
        var rz = '${rzResult}';
        if(rz == '0'){
            toast('请先实名认证',1000);
            setTimeout(function () {
                window.location.href = "http://gawx.daqing.gov.cn/econsole/weixin/econsole/weixin/percenter/oauth?t=" + Math.random();
            }, 1000);
        }else if(rz == '-9'){
            toast('实名认证不通过',1000);
            setTimeout(function () {
                window.location.href = "http://gawx.daqing.gov.cn/econsole/weixin/econsole/weixin/percenter/oauth?t=" + Math.random();
            }, 1000);
        }
    })

    function baoCun(){
        var guid = '${guid}';
        var hyzk = $('#hyzk').val();
        var mz = $('#mz').val();
//            var jg = $('#jg').val();
//            var xl = $('#xl').val();
//            var jdccllxbm = $('#jdccllxbm').val();
        if("${rzResult}"=="2"){
            toast("实名认证中，请等待认证结果", 2000);
            return false;
        }
        if(hyzk == ''){
            toast("请输入档案编号",2000);
            return false;
        }
        if(mz == ''){
            toast("请输入驾驶证编号",2000);
            return false;
        }
//            if(jg == ''){
//                toast("请输入车牌号",2000);
//                return false;
//            }
//            if(xl == ''){
//                toast("请输入发动机号后四位",2000);
//                return false;
//            }

        var fnFormat = /[a-z_A-Z_0-9]{12}/;
        if(!fnFormat.test(hyzk)){
            toast("请输入12位档案编号", 2000);
            return false;
        }

        var dabhFormat = /^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/;
        if(!dabhFormat.test(mz)){
            toast("请输入15/18位驾驶证编号", 2000);
            return false;
        }


//            if(jg.length != 6){
//                toast("请输入6位车牌号", 2000);
//                return false;
//            }
//
//            if(xl.length != 4){
//                toast("请输入发动机号后4位", 2000);
//                return false;
//            }

        <%--var pushId = '${pushId}';--%>
        <%--var pushType= '${pushType}';--%>
        $.ajax({
            url:"<c:url value='/api/bind'/>",
            <%--url : "<c:url value='/weixinquery/bdjsz'/>",--%>
            type : "get",
            data : {"guid":guid,"fn":hyzk,"drivingLicense":mz},
            contentType : "application/json;charser=utf-8",
            beforeSend: function () {
                loading();
            },
            success : function(resp){
//                    toast(resp,2000);
             //   $("#btn_query").attr("disabled", "disabled");
//                $("#btn_query").css("background-color", "#DDDDDD");

                finish();
                $("#result").html(resp.msg);
            },error:function(){

                finish();
                toast("绑定失败");
            }
        });
    }
</script>

</html>
